package cn.webrx;

import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Stream2 {
    public static void main(String[] args) {
        //List Stream
        List<String> list = List.of("a", "b", "c", "d", "e", "f");
        Stream<String> s1 = list.stream().skip(1).limit(3);
        s1.forEach(System.out::println);

        int[] num = {1, 2, 3};
        IntStream is = Arrays.stream(num);
        Stream<Integer> is2 = Stream.of(1, 2, 3);

        DoubleStream ds = DoubleStream.generate(() -> java.lang.Math.random()).limit(5);
        //ds.forEach(e->System.out.printf("%.2f ",e));
        ds.forEach(System.out::println);

        IntStream is3 = IntStream.generate(() -> {
            Random rand = new Random();
            return rand.nextInt(1, 101);
        }).limit(10);
        is3.forEach(System.out::println);
    }
}
